<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //题目一
        const arr = ['name','age','hhh','age','hhh','hhh','hhh','hhh']

        let obj1 = {}
        arr.forEach(item => {
            obj1[item] ? obj1[item] +=1 : obj1[item] = 1
        })
        console.log(obj1);

        //题目2
        const a = [1,2,3,5]
        const b = [1,3,5,6]

        let arr1 = []
        a.forEach(item => {
            if(b.indexOf(item)=== -1) arr1.push(item)
        })
        console.log(arr1);
        

        //题目3，数组去重
        const arr2 = [1,2,3,2,9]
        function qc(arr) {
            let obj={}
            let newArr=[]
            for (let i = 0;i<arr2.length;i++) {
                if(!obj[arr[i]]) {
                    obj[arr[i]] = 1
                    newArr.push(arr[i])
                }
            }
            return newArr
        }
        console.log(qc(arr2));
        
    </script>
</body>
</html>